<template>
  <el-input-number
      v-model="value"
      :disabled="disabled"
      :clearable="!field.not_null"
      controls-position="right"
      style="width: 100%"

      :min="format.min"
      :max="format.max"
      :step="format.step"
      :precision="format.precision"
      :step-strictly="format.step_strictly"
      :value-on-clear="field.not_null ? 0 : null"
  />


</template>

<script setup lang="ts">
import {computed} from "vue";
import type {MetaField, MetaFormat} from "../../../types/tool/meta.types.ts";
import type {DaoTypes} from "../../../types/tool/dao.types.ts";

/**
 * 通用
 */

const props = defineProps<{
  modelValue: any,
  disabled: boolean,
  db: DaoTypes,
  field: MetaField
}>();
const emits = defineEmits(['update:modelValue'])
const value = computed({
  get: () => props.modelValue,
  set: (v) => emits('update:modelValue', v)
})

const format = computed<MetaFormat>(() => {
  let {min, max, step, precision, step_strictly} = props.field.format || {}
  min = min === null ? undefined : min;
  max = max === null ? undefined : max;
  precision = precision === null ? undefined : precision;
  return {min, max, step, precision, step_strictly}
})


</script>

<style scoped>

</style>